package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.eduSystemConfig.EduSystemConfigKeyVO;
import com.jwsoft.manager.common.vo.eduSystemConfig.EduSystemConfigQueryVO;
import com.jwsoft.manager.common.vo.eduSystemConfig.EduSystemConfigVO;
import com.jwsoft.manager.core.integration.EduSystemConfigIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 教育系统配置网关
 *
 * @author dlb
 * @since 2023-02-02
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "教育系统配置", description = "教育系统配置")
public class EduSystemConfigController {

    @Autowired
    public EduSystemConfigIntegration eduSystemConfigIntegration;

    @Operation(summary = "教育系统配置分页查询",description = "教育系统配置分页查询")
    @PostMapping(value = "/EduSystemConfig0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduSystemConfigVO>> getList(@RequestBody @Validated EduSystemConfigQueryVO vo) {
        return AppResponse.successData(eduSystemConfigIntegration.getList(vo));
    }

    @Operation(summary = "教育系统配置根据主键查询详情",description = "教育系统配置根据主键查询详情")
    @PostMapping(value = "/EduSystemConfig0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSystemConfigVO> getById(@RequestBody @Validated EduSystemConfigKeyVO vo) {
        return AppResponse.successData(eduSystemConfigIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "教育系统配置新增",description = "教育系统配置新增")
    @PostMapping(value = "/EduSystemConfig0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSystemConfigVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduSystemConfigVO vo) {
        return AppResponse.successData(eduSystemConfigIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "教育系统配置修改",description = "教育系统配置修改")
    @PostMapping(value = "/EduSystemConfig0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSystemConfigVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduSystemConfigVO vo) {
        return AppResponse.successData(eduSystemConfigIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "教育系统配置删除",description = "教育系统配置删除")
    @PostMapping(value = "/EduSystemConfig0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduSystemConfigKeyVO vo) {
        eduSystemConfigIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }
}
